package com.qwc.blog.entity.vo.posts;

import com.qwc.blog.common.validate.IdValid;
import com.qwc.blog.entity.Content;
import com.qwc.blog.entity.Posts;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author qwc
 * @Date 2021/11/4 9:08
 */
@Data
public class AddPostDto {
    @NotNull(groups = IdValid.class, message = "文章主键不能为空")
    private Integer postsId;
    @NotBlank(message = "标题不能为空")
    private String title;
    private String summary;
    private String isComment;
    private Integer sort;
    private List<List<Integer>> categories;
    private List<String> tags;
    private String thumbnail;
    private String content;

    public Posts getPost() {
        Posts posts = new Posts();
        posts.setPostsId(postsId);
        posts.setTitle(title);
        posts.setSummary(summary);
        posts.setIsComment(isComment);
        posts.setSort(sort);
        posts.setThumbnail(thumbnail);
        return posts;
    }

    public Content getContent() {
        Content content = new Content();
        content.setContent(this.content);
        return content;
    }
}
